// https://www.nowcoder.com/practice/521cead04d1442899767578c3aa395f0

#include <iostream>
#include <vector>
using namespace std;

class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param target int整型
     * @param nums int整型vector
     * @return int整型
     */
    int change(int target, vector<int>& nums) {
        vector<int> dp(5005, -1);
        dp[0] = 1;
        for (int i = 0; i < nums.size(); i++) {
            for (int j = nums[i]; j <= target; j++) {
                if (dp[j - nums[i]] != -1) {
                    dp[j] = dp[j - nums[i]] + dp[nums[i]];
                }
            }
        }
        return dp[target];
    }
};